﻿using Microsoft.AspNetCore.Mvc;
using PowerHub.MES.Common.Utility;
using PowerHub.MES.DTO.Crew.DTO;
using PowerHub.MES.DTO.Crew.QueryDto;
using PowerHub.MES.DTO.Shopfloor.DTO;
using PowerHub.MES.DTO.Shopfloor.QueryDTO;
using PowerHub.MES.Entities.Crew;
using PowerHub.MES.Entities.Shopfloor;
using PowerHub.MES.IServices.ICrew;
using PowerHub.MES.IServices.IShopfloor;
using PowerHub.MES.ReturnEntity;

namespace PowerHub.MES.Controllers.Crew
{
    /// <summary>
    /// 排班计划
    /// </summary>
    [ApiController]
    [Route("Api/MES/Crew/[controller]/[action]")]
    public class SchedulingPlanController
    {

        private ICrew_SchedulingPlanServices _Crew_SchedulingPlanServices;

        public SchedulingPlanController(ICrew_SchedulingPlanServices SchedulingPlanServices)
        {
            _Crew_SchedulingPlanServices = SchedulingPlanServices;
        }

        /// <summary>
        /// 获取排班计划列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("获取排班计划列表")]

        public async Task<OperationPageResult<List<Crew_SchedulingPlan>>> GetCrew_SchedulingPlanPageListAsync([FromBody] QueryCrew_SchedulingPlanDTO pageQuery)
        {
            return await _Crew_SchedulingPlanServices.GetCrew_SchedulingPlanPageListAsync(pageQuery);
        }

        /// <summary>
        /// 根据班组id获取排班计划明细列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        public async Task<OperationPageResult<List<Crew_SchedulingPlanDetial>>> GetCrew_SchedulingPlanByIdDetialsPageListAsync([FromBody] QueryCrew_SchedulingPlanDTO pageQuery)
        {
            return await _Crew_SchedulingPlanServices.GetCrew_SchedulingPlanByIdDetialsPageListAsync(pageQuery);
        }


        /// <summary>
        /// 根据班组id获取排班计划
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("根据班组id获取排班计划")]
        public async Task<OperationResult<Crew_SchedulingPlanUpdateDto>> GetCrew_SchedulingPlanByIdAsync([FromBody] QueryCrew_SchedulingPlanDTO pageQuery)
        {
            return await _Crew_SchedulingPlanServices.GetCrew_SchedulingPlanByIdAsync(pageQuery);
        }

        /// <summary>
        /// 批量删除排班计划
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("批量删除排班计划")]
        public async Task<OperationResult<bool>> DeletionCrew_SchedulingPlanAsync([FromBody] List<string> Query)
        {
            return await _Crew_SchedulingPlanServices.DeletionCrew_SchedulingPlanAsync(Query);
        }

        /// <summary>
        /// 更新排班计划
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("更新排班计划")]
        public async Task<OperationResult<bool>> UpdateCrew_SchedulingPlanAsync([FromBody] Crew_SchedulingPlanDTO Query)
        {
            return await _Crew_SchedulingPlanServices.UpdateCrew_SchedulingPlanAsync(Query);
        }

        /// <summary>
        /// 根据计划Id绑定工单
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        public async Task<OperationResult<bool>> UpdateCrew_SchedulingPlanByBindWorkOrderAsync([FromBody] Crew_SchedulingPlanBindDTO Query)
        {
            return await _Crew_SchedulingPlanServices.UpdateCrew_SchedulingPlanByBindWorkOrderAsync(Query);
        }

        /// <summary>
        /// 根据明细id更新排班计划明细
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("根据明细id更新排班计划明细")]
        public async Task<OperationResult<bool>> UpdateCrew_SchedulingPlanDetialByIdAsync([FromBody] CrewSchedulingPlanDetialsDtos Query)
        {
            return await _Crew_SchedulingPlanServices.UpdateCrew_SchedulingPlanDetialByIdAsync(Query);
        }

        /// <summary>
        /// 添加排班计划
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("添加排班计划")]
        public async Task<OperationResult<bool>> CreateCrew_SchedulingPlanAsync([FromBody] Crew_SchedulingPlanDTO Query)
        {
            return await _Crew_SchedulingPlanServices.CreateCrew_SchedulingPlanAsync(Query);
        }
    }
}
